package com.zeratul.web.validate.annotation;

import com.zeratul.web.validate.handler.ZtSpelValidateHandler;
import com.zeratul.web.validate.handler.ZtValidateHandler;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.*;

/**
 * 指定参数校验注解
 */
@Repeatable(ZtValid.ZtValids.class)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = ZtValidateHandler.class)
public @interface ZtValid {

    /**
     * 异常提醒信息
     * @return
     */
    String message() default "";

    /**
     * 分组校验
     * @return
     */
    Class<?>[] groups() default { };

    /**
     * 校验等级
     * @return
     */
    Class<? extends Payload>[] payload() default { };

    /**
     * spel表达式
     */
    String spel() default "";

    /**
     * 自定义参数校验逻辑处理器
     * @return
     */
    Class<? extends ZtValidateHandler> handler() default ZtSpelValidateHandler.class;

    @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @interface ZtValids {

        ZtValid[] value();
    }

}
